window.onload = function(){   
 var list = document.getElementById('list');   
 var ah2 = list.getElementsByTagName('h2');   
 var ul2 = list.getElementsByClassName("lis_ul");

  var ul3 = list.getElementsByClassName('list_ul')
 var ah3 = list.getElementsByTagName('h3');   
  console.log(ah2.length) 
  console.log(ul2.length) 
  console.log(ul3.length)
 // h2要和下面的ul进行匹配，所以我们要用索引值，给h2身上添加索引值
 for(var i=0;i<ah2.length;i++){    
  ah2[i].index = i;//给h2添加索引值，点击谁就给谁添加索引值
  ah2[i].onclick = function(){
   if(this.className == ''){//判断所点击的h2标签是否有类，
    //this.index指h2身上的索引数，this指h2，h2的索引值为this.index
    console.log(this.index)
    ul2[this.index].style.display = 'block'; 
    this.className = 'active';//给当前点击的h2添加类，更改箭头方向
   }else{
    ul2[this.index].style.display = 'none';
    this.className = '';
   }
  }
 }
 for(var i=0;i<ah3.length;i++){    
  ah3[i].index = i;//给h2添加索引值，点击谁就给谁添加索引值
  ah3[i].onclick = function(){
   if(this.className == ''){//判断所点击的h2标签是否有类，
    //this.index指h2身上的索引数，this指h2，h2的索引值为this.index
    ul3[this.index].style.display = 'block'; 
    var sum= ul3[this.index].children;
     console.log(this.style.height)
      console.log(sum)
    this.style.height=80*sum+'px';
    console.log(this.style.height)
    this.className = 'on';//给当前点击的h2添加类，更改箭头方向
   }else{
    ul3[this.index].style.display = 'none';
    this.className = '';
   }
  }
 }
}